<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Seeks to pos on fd from whence</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.dio-read.html">« dio_read</a></li>
      <li style="float: right;"><a href="function.dio-stat.html">dio_stat »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.dio.html">Direct IO 函数</a></li>
    <li>Seeks to pos on fd from whence</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.dio-seek" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">dio_seek</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5 &lt; 5.1.0)</p><p class="refpurpose"><span class="refname">dio_seek</span> &mdash; <span class="dc-title">Seeks to pos on fd from whence</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.dio-seek-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>dio_seek</strong></span>(<span class="methodparam"><span class="type">resource</span> <code class="parameter">$fd</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$pos</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$whence</code><span class="initializer"> = SEEK_SET</span></span>): <span class="type">int</span></div>

  <p class="para rdfs-comment">
   The function <span class="function"><strong>dio_seek()</strong></span> is used to change the
   file position of the given file descriptor.  
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.dio-seek-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">fd</code></dt>

     <dd>

      <p class="para">
       The file descriptor returned by <span class="function"><a href="function.dio-open.html" class="function">dio_open()</a></span>.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">pos</code></dt>

     <dd>

      <p class="para">
       The new position.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">whence</code></dt>

     <dd>

      <p class="para">
       Specifies how the position <code class="parameter">pos</code> should be 
       interpreted:
       <ul class="itemizedlist">
        <li class="listitem">
         <p class="para">
          <strong><code>SEEK_SET</code></strong> (default) - specifies that 
          <code class="parameter">pos</code> is specified from the beginning of the 
          file.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>SEEK_CUR</code></strong> - Specifies that 
          <code class="parameter">pos</code> is a count of characters from the current
          file position. This count may be positive or negative.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>SEEK_END</code></strong> - Specifies that 
          <code class="parameter">pos</code> is a count of characters from the end of
          the file. A negative count specifies a position within the current 
          extent of the file; a positive count specifies a position past the 
          current end. If you set the position past the current end, and 
          actually write data, you will extend the file with zeros up to that
          position.
         </p>
        </li>
       </ul>
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.dio-seek-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.dio-seek-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2122">
    <p><strong>示例 #1 Positioning in a file</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$fd&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">dio_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'/dev/ttyS0'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">O_RDWR</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">dio_seek</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SEEK_SET</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;position&nbsp;is&nbsp;now&nbsp;at&nbsp;10&nbsp;characters&nbsp;from&nbsp;the&nbsp;start&nbsp;of&nbsp;the&nbsp;file<br /><br /></span><span style="color: #0000BB">dio_seek</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SEEK_CUR</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;position&nbsp;is&nbsp;now&nbsp;at&nbsp;8&nbsp;characters&nbsp;from&nbsp;the&nbsp;start&nbsp;of&nbsp;the&nbsp;file<br /><br /></span><span style="color: #0000BB">dio_seek</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">5</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SEEK_END</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;position&nbsp;is&nbsp;now&nbsp;at&nbsp;5&nbsp;characters&nbsp;from&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;file<br /><br /></span><span style="color: #0000BB">dio_seek</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SEEK_END</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;position&nbsp;is&nbsp;now&nbsp;at&nbsp;10&nbsp;characters&nbsp;past&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;file.&nbsp;<br />//&nbsp;The&nbsp;10&nbsp;characters&nbsp;between&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;file&nbsp;and&nbsp;the&nbsp;current<br />//&nbsp;position&nbsp;are&nbsp;filled&nbsp;with&nbsp;zeros.<br /><br /></span><span style="color: #0000BB">dio_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>     
  </p>
 </div>

</div></div></div></body></html>